#!/bin/bash
# Zaitan Module - Tomcat6 Install
# Zaitan Team <http://code.google.com/p/zaitan/>

RMOD_ENGINE='1.0'
RMOD_CATEGORY='Software'
RMOD_SUBCATEGORY='Developed'
RMOD_NAME='Tomcat6'
RMOD_AUTHOR='Zaitan Team'
RMOD_VERSION='6.0.13'
RMOD_DESCRIPTION='Installs Tomcat6'



# Install Tomcat6


echo Running $RMOD_NAME...
#/usr/lib/zaitan/modulo/mod-checkInstall


	cd /usr/share/zaitan
	wget -c http://ftp.pucpr.br/apache/tomcat/tomcat-6/v6.0.13/bin/apache-tomcat-6.0.13.tar.gz
	tar -xzvf apache-tomcat-6.0.13.tar.gz
	mv apache-tomcat-6.0.13 /etc/opt/tomcat-6
	cp /etc/opt/tomcat-6/lib/servlet-api.jar /usr/lib/jvm/java-6-sun/jre/lib/ext/

echo 'JAVA_HOME=/usr/lib/jvm/java-6-sun
export JAVA_HOME

CATALINA_HOME=/etc/opt/tomcat-6
export CATALINA_HOME

TOMCAT_HOME=/etc/opt/tomcat-6
export TOMCAT_HOME ' | tee -a /etc/profile

	
echo '#!/bin/bash

case $1 in

"start" )
/etc/opt/tomcat-6/bin/startup.sh
;;

"stop" )
/etc/opt/tomcat-6/bin/shutdown.sh
;;

*)
    echo "Use: tomcat6 {start|stop|}" && sleep 1
    exit -1
    ;;

esac' > tomcat6

chmod +x tomcat6 && mv tomcat6 /usr/bin

sleep 2
echo $RMOD_NAME Finibashed...

##Logs
echo $RMOD_NAME-$RMOD_VERSION | tee -a /usr/share/zaitan/logs
/usr/lib/zaitan/modulo/mod-logs
##

exit 0

